<template>
  <div>
    <router-view />
  </div>
</template>


<script>

import {format} from "../../api/index";
import BannerMain from '../../components/banner/bannermain'
import BannerShow from '../../components/banner/bannershow'

export default {
  name: "Banner",
  components: {
    BannerMain,
    BannerShow
  },
  data() {
    return {
      showBanner: true,
      helpBannerData: {}, // 修改的轮播图对象
      showDialog: false,
      tableData: []
    }
  },

  created() {
    // this.getList();
  },

  methods: {
    /*去展示*/
    gotoShow() {
      this.$router.push({name: 'ShowBanner'})
    },


    /*消息提示*/
    getPrompt(id) {
      return `确认删除当前轮播图吗？删除无法回退`;
    },

    /*添加轮播图*/
    addBanner() {
      this.$refs.childerBanner.transitionVisible();
    },

    /*查询需要编辑的轮播图*/
    handleEdit(index, row) {
      this.$axios.get('/BannerServlet?method=findOne', {
        params: {
          id: row.id
        }
      }).then((res) => {
        console.log(res);
        this.helpBannerData = res.data.data;
        this.$refs.childerEdit.dialogTableVisible = true;
      })
    },

    /*删除轮播图*/
    handleDelete(row) {
      this.$axios.get('/BannerServlet?method=delete', {
        params: {
          id: row.id
        }
      }).then((res) => {
        this.$message({
          message: '删除成功',
          type: 'success'
        });

        this.getList();
      })
    },

    /* 将所有幻灯片查询出来 */
    getList() {
      this.$axios.get('/BannerServlet?method=queryData')
        .then((res) => {
          console.log(res);
          this.tableData = res.data.data;
          this.tableData.forEach((e) => {
            e.updateTime = format(e.updateTime)
          })
        })
        .catch((err) => {

        })
    }
  }
}
</script>

<style scoped>
.el-row {
  margin-bottom: 10px;
}
</style>
